package com.triones.api.controller.web.interlace;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.triones.api.entity.interlace.bo.InterlaceCardApplyParams;
import com.triones.api.entity.interlace.bo.InterlaceCardTransactionParams;
import com.triones.api.entity.interlace.bo.InterlaceInfinityCardParams;
import com.triones.api.entity.interlace.dto.InterlaceCardApplyDO;
import com.triones.api.entity.interlace.vo.CustomInterlaceCardTransactionVO;
import com.triones.api.entity.interlace.vo.CustomInterlaceInfinityCardVO;
import com.triones.api.entity.interlace.vo.InterlaceCardApplyVO;
import com.triones.api.service.interlace.InterlaceCardService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 卡管理
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/interlace/card")
public class InterlaceCardController extends BaseController {

    private final InterlaceCardService interlaceCardService;

    /**
     * interlace卡列表（分页）
     */
    @SaCheckPermission("system:interlaceCard:pageList")
    @GetMapping("/pageList")
    public TableDataInfo<CustomInterlaceInfinityCardVO> pageList(InterlaceInfinityCardParams params, PageQuery pageQuery) {
        return interlaceCardService.pageList(params,pageQuery);
    }

    /**
     * 卡详情
     */
    @SaCheckPermission("system:interlaceCard:query")
    @GetMapping("/detail/{id}")
    public R<CustomInterlaceInfinityCardVO> getDetail(@PathVariable("id") Long id) {
        return R.ok(interlaceCardService.getDetail(id));
    }

    /**
     * interlace卡交易列表（分页）
     */
    @SaCheckPermission("system:cardTransaction:pageList")
    @GetMapping("/transaction/pageList")
    public TableDataInfo<CustomInterlaceCardTransactionVO> transactionPageList(InterlaceCardTransactionParams params, PageQuery pageQuery) {
        return interlaceCardService.transactionPageList(params,pageQuery);
    }

    /**
     * 卡交易详情
     */
    @SaCheckPermission("system:cardTransaction:query")
    @GetMapping("/transaction/detail/{id}")
    public R<CustomInterlaceCardTransactionVO> getTransactionDetail(@PathVariable("id") Long id) {
        return R.ok(interlaceCardService.getTransactionDetail(id));
    }

    /**
     * 卡申请记录（分页）
     */
    @SaCheckPermission("system:cardApply:pageList")
    @GetMapping("/apply/pageList")
    public TableDataInfo<InterlaceCardApplyVO> applyPageList(InterlaceCardApplyParams params, PageQuery pageQuery) {
        return interlaceCardService.applyPageList(params,pageQuery);
    }

    /**
     * 删除银行卡卡片
     */
    @SaCheckPermission("system:interlaceCard:delete")
    @DeleteMapping("/card/del/{id}")
    public R<Void> delCard(@PathVariable @NotNull(message = "卡主键不能为空") Long id) {
        return toAjax(interlaceCardService.delCard(id));
    }
}
